/**
 * 
 */
package user.service.zconfigurer;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.alibaba.dubbo.config.ApplicationConfig;
import com.alibaba.dubbo.config.ProtocolConfig;
import com.alibaba.dubbo.config.ProviderConfig;
import com.alibaba.dubbo.config.RegistryConfig;
import com.alibaba.dubbo.config.spring.AnnotationBean;

import user.service.Application;

/**
 * @author Eric
 */
@Configuration
public class DubboServerConfig {
	@Bean
    public ProtocolConfig protocolConfig() {
        ProtocolConfig protocol = new ProtocolConfig();
        protocol.setName("dubbo");
        protocol.setPort(38888);
        return protocol;
    }

    @Bean
    public ApplicationConfig appConfig() {
        ApplicationConfig app = new ApplicationConfig();
        app.setName("user-service");
        return app;
    }

    @Bean
    public RegistryConfig registryConfig() {
        RegistryConfig registry = new RegistryConfig();
        registry.setAddress("zookeeper://zookeeper:2181");
        return registry;
    }

    @Bean
    public ProviderConfig providerConfig() {
        ProviderConfig provider = new ProviderConfig();
        provider.setRetries(0);
        provider.setTimeout(7000);
        return provider;
    }

    @Bean
    public AnnotationBean annotationConfig() {
        AnnotationBean bean = new AnnotationBean();
        bean.setPackage(Application.class.getPackage().getName());
        return bean;
    }
}
